package edu.hit.irlab.coref.features.pair;

import java.util.List;

import edu.hit.irlab.coref.PairFeatureExtractor;
import edu.hit.irlab.coref.PairInstance;

import nlpeap.feature.basictypes.NumberType;
import nlpeap.ml.TriValue;
import nlpeap.ml.FeatureDescription;
import nlpeap.ml.FeatureType;


/**
 * Feature used to determine whether number of the pair instance matches.
 * The values are Either TRUE/FALSE/UNKNOWN<br>
 * If the number type of one mention is UNKNOWN, then return UNKNOWN,
 * then return whether the number type of the two mentions are equal
 * 
 * @author chuter
 */
public class FE_Number implements PairFeatureExtractor{
    public static final FeatureDescription<TriValue> FD_IS_NUMBER=
            new FeatureDescription<TriValue>(FeatureType.FT_NOMINAL_ENUM, TriValue.class, "Number");
    
    public void describeFeatures(List<FeatureDescription> fds) {
        fds.add(FD_IS_NUMBER);
    }

    public void extractFeatures(PairInstance inst) 
    {
    	if (inst.getAnaphor().getNumber().equals(NumberType.UNKNOWN)
    		|| inst.getAntecedent().getNumber().equals(NumberType.UNKNOWN))
    		inst.setFeature(FD_IS_NUMBER, TriValue.UNKNOW);
    	else {
    		if (inst.getAnaphor().getNumber() == inst.getAntecedent().getNumber())
    			inst.setFeature(FD_IS_NUMBER, TriValue.TRUE);
    		else
    			inst.setFeature(FD_IS_NUMBER, TriValue.FALSE);
    	}
    	
    }

}

